<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Website_model extends CI_Model {

	public function __construct()
	{
		parent::__construct();
	}
	
	// ------------------------------------------------------------------------
	
	public function list_websites()
	{
		$query = $this->db->where('deleted', 'n')
						  ->order_by('site_name')
						  ->get('websites');
						  
		return $query->num_rows() > 0 ? $query->result_array() : FALSE;
	}
	
	// ------------------------------------------------------------------------
	
	public function create_user_websites($fields, $user_id)
	{
		foreach ($fields as $website)
		{
			$data[] = array(
				'site_code'		=> $website,
				'user_id'		=> $user_id
			);
		}
		
		if (! $data) return TRUE;
		
		return $this->db->insert_batch('user_websites', $data);
	}
	
	// ------------------------------------------------------------------------

}

/* End of file website_model.php */
/* Location: ./application/models/website_model.php */